package inc.zhugastrov.sellerform;

import java.math.BigDecimal;
import java.util.List;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Table;

import org.eclipse.persistence.annotations.Direction;
import org.eclipse.persistence.annotations.NamedStoredProcedureQuery;
import org.eclipse.persistence.annotations.StoredProcedureParameter;

@Entity
@Table(name="\"ORDER\"")

public class Order implements OrderIntr {

	private String date;
	@Id
	@Column(name="ORDER_ID")
	private Long id;
	private Double totalPrice;
	private String sellerId;
	
	@ElementCollection(targetClass=OrderedItems.class)
	@CollectionTable(name="ORDERED",
                    joinColumns=@JoinColumn(name="ORDER_ID"))
	private List<OrderedItems> items;

	public Double getTotalPrice() {
		return totalPrice;
	}

	public void setTotalPrice(Double totalPrice) {
		BigDecimal round = new BigDecimal(totalPrice.doubleValue()).setScale(3,
				BigDecimal.ROUND_HALF_DOWN);
		this.totalPrice = new Double(round.doubleValue());
	}
	public List<OrderedItems> getItems() {
		return items;
	}
	
	public <OrderedItems> void setItems(List<OrderedItems> items) {
		this.items = (List<inc.zhugastrov.sellerform.OrderedItems>) items;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getSellerId() {
		return sellerId;
	}

	public void setSellerId(String sellerId) {
		this.sellerId = sellerId;
	}
}
